#include <iostream>
#include "Exception.h"

using namespace DTLib;
using namespace std;

void DemoNullPointerException()
{
    try
    {
        THROW_EXCEPTION(NullPointerException, "test");
    }
    catch(const NullPointerException& e)
    {
        cout << "catch(const NullPointerException& e)" << endl;
        cout << "[" << e.location() << "]: " << e.message() << endl;
    }
}

void DemoIndexOutOfBoundsException()
{
    try
    {
        THROW_EXCEPTION(IndexOutOfBoundsException, "test");
    }
    catch(const IndexOutOfBoundsException& e)
    {
        cout << "catch(const IndexOutOfBoundsException& e)" << endl;
        cout << "[" << e.location() << "]: " << e.message() << endl;
    }
}

void DemoNoEnoughMemoryException()
{
    try
    {
        THROW_EXCEPTION(NoEnoughMemoryException, "test");
    }
    catch(const NoEnoughMemoryException& e)
    {
        cout << "catch(const NoEnoughMemoryException& e)" << endl;
        cout << "[" << e.location() << "]: " << e.message() << endl;
    }
}

void DemoInvalidParameterException()
{
    try
    {
        THROW_EXCEPTION(InvalidParameterException, "test");
    }
    catch(const InvalidParameterException& e)
    {
        cout << "catch(const InvalidParameterException & e)" << endl;
        cout << "[" << e.location() << "]: " << e.message() << endl;
    }
}

int main()
{
    DemoNullPointerException();
    DemoIndexOutOfBoundsException();
    DemoNoEnoughMemoryException();
    DemoInvalidParameterException();
    return 0;
}
